Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./n1_n2_cleaned_cases.rds")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2020-03-14"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2020-03-28"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.25, n = 835)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 13.04903 13.04432 13.03967 13.03507 13.03052 13.02602 13.02158 13.01719
## [9] 13.01285 13.00856 13.00433 13.00014 12.99601 12.99192 12.98788 12.98390
## [17] 12.97996 12.97607 12.97223 12.96844 12.96469 12.96099 12.95734 12.95373
## [25] 12.95017 12.94665 12.94318 12.93976 12.93637 12.93304 12.92974 12.92649
## [33] 12.92328 12.92011 12.91699 12.91391 12.91087 12.90787 12.90490 12.90198
## [41] 12.89910 12.89626 12.89346 12.89071 12.88801 12.88538 12.88281 12.88029
## [49] 12.87784 12.87545 12.87311 12.87084 12.86862 12.86647 12.86438 12.86234
## [57] 12.86036 12.85845 12.85659 12.85480 12.85306 12.85138 12.84976 12.84821
## [65] 12.84671 12.84527 12.84389 12.84257 12.84131 12.84011 12.83896 12.83788
## [73] 12.83686 12.83589 12.83499 12.83415 12.83336 12.83263 12.83197 12.83136
## [81] 12.83081 12.83032 12.82989 12.82952 12.82920 12.82895 12.82876 12.82862
## [89] 12.82855 12.82853 12.82857 12.82867 12.82883 12.82903 12.82929 12.82960
## [97] 12.82995 12.83036 12.83082 12.83133 12.83189 12.83250 12.83316 12.83387
## [105] 12.83463 12.83544 12.83631 12.83722 12.83819 12.83921 12.84027 12.84139
## [113] 12.84256 12.84378 12.84506 12.84638 12.84776 12.84918 12.85066 12.85219
## [121] 12.85377 12.85540 12.85709 12.85883 12.86061 12.86245 12.86435 12.86629
## [129] 12.86829 12.87033 12.87243 12.87458 12.87679 12.87904 12.88135 12.88457
## [137] 12.88943 12.89576 12.90341 12.91220 12.92196 12.93252 12.94371 12.95537
## [145] 12.96732 12.97941 12.99145 13.00328 13.01474 13.02565 13.03584 13.04514
## [153] 13.05340 13.06043 13.06607 13.07015 13.07399 13.07894 13.08494 13.09188
## [161] 13.09970 13.10830 13.11760 13.12751 13.13796 13.14886 13.16011 13.17165
## [169] 13.18339 13.19523 13.20710 13.21892 13.23059 13.24204 13.25317 13.26391
## [177] 13.27418 13.28388 13.29293 13.30126 13.30876 13.31537 13.32100 13.32555
## [185] 13.32896 13.33113 13.33198 13.33142 13.32937 13.32615 13.32213 13.31737
## [193] 13.31189 13.30575 13.29899 13.29164 13.28375 13.27536 13.26651 13.25724
## [201] 13.24759 13.23760 13.22732 13.21678 13.20603 13.19511 13.18406 13.17291
## [209] 13.16172 13.15053 13.13936 13.12827 13.11600 13.10136 13.08455 13.06574
## [217] 13.04510 13.02283 12.99909 12.97406 12.94793 12.92088 12.89308 12.86471
## [225] 12.83594 12.80697 12.77797 12.74912 12.72059 12.69256 12.66522 12.63875
## [233] 12.61331 12.58910 12.56629 12.54505 12.52557 12.50804 12.49096 12.47282
## [241] 12.45374 12.43385 12.41325 12.39208 12.37045 12.34847 12.32627 12.30397
## [249] 12.28169 12.25954 12.23765 12.21613 12.19511 12.17470 12.15502 12.13619
## [257] 12.11834 12.10157 12.08602 12.07174 12.05865 12.04666 12.03567 12.02559
## [265] 12.01633 12.00778 11.99986 11.99247 11.98551 11.97889 11.97251 11.96629
## [273] 11.96012 11.95391 11.94757 11.94100 11.93410 11.92679 11.91896 11.91052
## [281] 11.90138 11.89144 11.88134 11.87176 11.86267 11.85403 11.84581 11.83797
## [289] 11.83048 11.82330 11.81640 11.80975 11.80331 11.79705 11.79093 11.78492
## [297] 11.77899 11.77309 11.76721 11.76129 11.75532 11.74924 11.74304 11.73667
## [305] 11.73010 11.72330 11.71624 11.70887 11.70056 11.69080 11.67976 11.66760
## [313] 11.65448 11.64056 11.62601 11.61097 11.59563 11.58013 11.56464 11.54932
## [321] 11.53433 11.51984 11.50601 11.49299 11.48095 11.47005 11.46046 11.45233
## [329] 11.44582 11.44110 11.43834 11.43585 11.43200 11.42697 11.42095 11.41414
## [337] 11.40671 11.39887 11.39079 11.38267 11.37470 11.36707 11.35996 11.35357
## [345] 11.34808 11.34369 11.34058 11.33895 11.33897 11.34085 11.34476 11.35091
## [353] 11.35947 11.37038 11.38350 11.39868 11.41576 11.43460 11.45503 11.47691
## [361] 11.50009 11.52441 11.54972 11.57587 11.60271 11.63008 11.65784 11.68583
## [369] 11.71390 11.74189 11.76966 11.79706 11.82393 11.85011 11.87547 11.89983
## [377] 11.92307 11.94501 11.96551 11.98443 12.00440 12.02792 12.05461 12.08406
## [385] 12.11590 12.14972 12.18515 12.22177 12.25921 12.29708 12.33497 12.37250
## [393] 12.40929 12.44493 12.47904 12.51122 12.54109 12.56825 12.59231 12.61288
## [401] 12.62957 12.64415 12.65863 12.67299 12.68719 12.70121 12.71500 12.72855
## [409] 12.74181 12.75476 12.76737 12.77960 12.79142 12.80281 12.81373 12.82415
## [417] 12.83403 12.84336 12.85209 12.86020 12.86765 12.87441 12.88046 12.88576
## [425] 12.89028 12.89398 12.89685 12.89787 12.89626 12.89224 12.88606 12.87795
## [433] 12.86816 12.85694 12.84451 12.83112 12.81701 12.80242 12.78760 12.77278
## [441] 12.75820 12.74411 12.73075 12.71835 12.70715 12.69740 12.68935 12.68322
## [449] 12.67693 12.66837 12.65776 12.64531 12.63123 12.61572 12.59901 12.58131
## [457] 12.56282 12.54376 12.52433 12.50476 12.48526 12.46602 12.44728 12.42923
## [465] 12.41210 12.39609 12.38141 12.36827 12.35690 12.34749 12.34027 12.33389
## [473] 12.32693 12.31947 12.31156 12.30329 12.29473 12.28594 12.27701 12.26800
## [481] 12.25898 12.25003 12.24122 12.23262 12.22430 12.21634 12.20880 12.20177
## [489] 12.19530 12.18948 12.18437 12.18005 12.17658 12.17405 12.17252 12.17207
## [497] 12.17276 12.17523 12.17993 12.18670 12.19537 12.20579 12.21779 12.23119
## [505] 12.24585 12.26158 12.27824 12.29564 12.31363 12.33205 12.35072 12.36949
## [513] 12.38819 12.40665 12.42470 12.44219 12.45896 12.47482 12.48962 12.50320
## [521] 12.51539 12.52603 12.53494 12.54197 12.54695 12.55146 12.55713 12.56385
## [529] 12.57149 12.57995 12.58911 12.59887 12.60910 12.61969 12.63054 12.64152
## [537] 12.65253 12.66345 12.67417 12.68458 12.69456 12.70400 12.71278 12.72080
## [545] 12.72794 12.73409 12.73913 12.74295 12.74545 12.74649 12.74598 12.74380
## [553] 12.73984 12.73394 12.72615 12.71661 12.70549 12.69295 12.67913 12.66419
## [561] 12.64830 12.63160 12.61426 12.59642 12.57825 12.55991 12.54154 12.52331
## [569] 12.50537 12.48788 12.47100 12.45487 12.43967 12.42553 12.41263 12.40112
## [577] 12.38883 12.37371 12.35605 12.33614 12.31430 12.29080 12.26595 12.24005
## [585] 12.21339 12.18627 12.15898 12.13182 12.10509 12.07908 12.05410 12.03043
## [593] 12.00838 11.98823 11.97030 11.95487 11.94224 11.93041 11.91729 11.90300
## [601] 11.88769 11.87149 11.85453 11.83695 11.81888 11.80046 11.78183 11.76311
## [609] 11.74445 11.72599 11.70784 11.69016 11.67307 11.65672 11.64123 11.62674
## [617] 11.61339 11.60131 11.59064 11.58151 11.57406 11.56842 11.56473 11.56310
## [625] 11.56344 11.56559 11.56941 11.57474 11.58143 11.58933 11.59827 11.60812
## [633] 11.61871 11.62990 11.64153 11.65345 11.66550 11.67753 11.68939 11.70092
## [641] 11.71198 11.72241 11.73205 11.74076 11.75017 11.76187 11.77567 11.79137
## [649] 11.80877 11.82767 11.84787 11.86917 11.89136 11.91425 11.93764 11.96133
## [657] 11.98512 12.00881 12.03219 12.05507 12.07725 12.09853 12.11871 12.13758
## [665] 12.15495 12.17062 12.18439 12.19744 12.21106 12.22519 12.23978 12.25479
## [673] 12.27014 12.28580 12.30170 12.31780 12.33403 12.35036 12.36672 12.38306
## [681] 12.39932 12.41546 12.43143 12.44715 12.46260 12.47770 12.49241 12.50668
## [689] 12.52044 12.53366 12.54626 12.55821 12.56945 12.57991 12.58956 12.59855
## [697] 12.60706 12.61514 12.62281 12.63009 12.63701 12.64358 12.64985 12.65582
## [705] 12.66153 12.66700 12.67226 12.67733 12.68224 12.68701 12.69166 12.69623
## [713] 12.70073 12.70519 12.70963 12.71409 12.71859 12.72314 12.72778 12.73253
## [721] 12.73742 12.74220 12.74663 12.75074 12.75455 12.75808 12.76136 12.76441
## [729] 12.76725 12.76990 12.77240 12.77476 12.77701 12.77917 12.78127 12.78332
## [737] 12.78535 12.78739 12.78946 12.79158 12.79378 12.79608 12.79840 12.80064
## [745] 12.80279 12.80487 12.80685 12.80875 12.81054 12.81224 12.81383 12.81531
## [753] 12.81668 12.81794 12.81907 12.82008 12.82096 12.82171 12.82233 12.82280
## [761] 12.82313 12.82332 12.82335 12.82322 12.82294 12.82249 12.82186 12.82105
## [769] 12.82009 12.81897 12.81771 12.81631 12.81478 12.81313 12.81137 12.80950
## [777] 12.80754 12.80548 12.80335 12.80114 12.79886 12.79653 12.79415 12.79173
## [785] 12.78928 12.78680 12.78426 12.78163 12.77890 12.77608 12.77316 12.77015
## [793] 12.76704 12.76384 12.76054 12.75714 12.75365 12.75006 12.74638 12.74260
## [801] 12.73872 12.73474 12.73067 12.72650 12.72224 12.71787 12.71341 12.70886
## [809] 12.70420 12.69945 12.69459 12.68965 12.68460 12.67945 12.67421 12.66886
## [817] 12.66341 12.65786 12.65222 12.64647 12.64062 12.63467 12.62862 12.62247
## [825] 12.61622 12.60987 12.60341 12.59686 12.59021 12.58345 12.57660 12.56965
## [833] 12.56259 12.55543 12.54818
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./plotly_objs/p_wrf_a.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.25, n = 835)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 12.60504 12.60118 12.59740 12.59370 12.59007 12.58652 12.58304 12.57964
## [9] 12.57632 12.57307 12.56990 12.56680 12.56378 12.56084 12.55797 12.55518
## [17] 12.55247 12.54983 12.54727 12.54478 12.54237 12.54004 12.53778 12.53560
## [25] 12.53350 12.53147 12.52952 12.52765 12.52586 12.52414 12.52250 12.52093
## [33] 12.51944 12.51803 12.51670 12.51544 12.51426 12.51316 12.51213 12.51119
## [41] 12.51031 12.50952 12.50880 12.50818 12.50765 12.50722 12.50689 12.50666
## [49] 12.50652 12.50648 12.50654 12.50668 12.50693 12.50726 12.50768 12.50820
## [57] 12.50881 12.50950 12.51028 12.51115 12.51211 12.51315 12.51428 12.51549
## [65] 12.51678 12.51816 12.51962 12.52116 12.52277 12.52447 12.52625 12.52810
## [73] 12.53003 12.53203 12.53411 12.53627 12.53849 12.54079 12.54316 12.54560
## [81] 12.54811 12.55069 12.55334 12.55605 12.55884 12.56168 12.56459 12.56757
## [89] 12.57061 12.57371 12.57687 12.58010 12.58351 12.58722 12.59123 12.59551
## [97] 12.60006 12.60486 12.60989 12.61515 12.62062 12.62629 12.63214 12.63816
## [105] 12.64434 12.65066 12.65711 12.66368 12.67035 12.67711 12.68395 12.69085
## [113] 12.69779 12.70478 12.71178 12.71880 12.72581 12.73280 12.73976 12.74667
## [121] 12.75353 12.76031 12.76701 12.77361 12.78010 12.78646 12.79268 12.79875
## [129] 12.80465 12.81038 12.81591 12.82123 12.82633 12.83189 12.83849 12.84602
## [137] 12.85438 12.86343 12.87308 12.88320 12.89367 12.90439 12.91523 12.92608
## [145] 12.93683 12.94736 12.95755 12.96729 12.97647 12.98496 12.99266 12.99945
## [153] 13.00521 13.00982 13.01472 13.02132 13.02947 13.03904 13.04987 13.06183
## [161] 13.07477 13.08856 13.10304 13.11808 13.13353 13.14925 13.16511 13.18094
## [169] 13.19662 13.21201 13.22695 13.24130 13.25493 13.26769 13.27943 13.29002
## [177] 13.29932 13.30717 13.31344 13.31799 13.32066 13.32133 13.32032 13.31808
## [185] 13.31469 13.31020 13.30466 13.29814 13.29069 13.28237 13.27325 13.26338
## [193] 13.25281 13.24162 13.22985 13.21757 13.20483 13.19169 13.17822 13.16446
## [201] 13.15049 13.13635 13.12211 13.10782 13.09354 13.07934 13.06527 13.05139
## [209] 13.03776 13.02443 13.01147 12.99894 12.98539 12.96950 12.95144 12.93141
## [217] 12.90960 12.88620 12.86140 12.83540 12.80837 12.78052 12.75204 12.72311
## [225] 12.69392 12.66468 12.63556 12.60676 12.57847 12.55088 12.52417 12.49856
## [233] 12.47421 12.45133 12.43010 12.41072 12.39337 12.37825 12.36424 12.35013
## [241] 12.33595 12.32172 12.30748 12.29324 12.27903 12.26489 12.25083 12.23690
## [249] 12.22311 12.20949 12.19607 12.18288 12.16994 12.15729 12.14494 12.13293
## [257] 12.12129 12.11004 12.09920 12.08949 12.08149 12.07504 12.07001 12.06624
## [265] 12.06358 12.06188 12.06101 12.06080 12.06111 12.06179 12.06269 12.06367
## [273] 12.06457 12.06525 12.06556 12.06535 12.06447 12.06278 12.06012 12.05634
## [281] 12.05131 12.04486 12.03802 12.03188 12.02638 12.02146 12.01706 12.01313
## [289] 12.00961 12.00644 12.00357 12.00093 11.99848 11.99614 11.99387 11.99161
## [297] 11.98931 11.98689 11.98431 11.98151 11.97844 11.97503 11.97122 11.96697
## [305] 11.96221 11.95688 11.95093 11.94431 11.93611 11.92566 11.91317 11.89887
## [313] 11.88299 11.86577 11.84742 11.82818 11.80827 11.78793 11.76738 11.74684
## [321] 11.72656 11.70676 11.68766 11.66949 11.65249 11.63687 11.62288 11.61073
## [329] 11.60066 11.59289 11.58766 11.58293 11.57666 11.56907 11.56036 11.55073
## [337] 11.54039 11.52955 11.51841 11.50719 11.49607 11.48528 11.47502 11.46549
## [345] 11.45691 11.44947 11.44338 11.43886 11.43610 11.43531 11.43671 11.44048
## [353] 11.44667 11.45504 11.46547 11.47781 11.49194 11.50770 11.52497 11.54360
## [361] 11.56345 11.58439 11.60628 11.62898 11.65236 11.67626 11.70057 11.72513
## [369] 11.74981 11.77447 11.79897 11.82318 11.84695 11.87015 11.89265 11.91429
## [377] 11.93495 11.95448 11.97275 11.98962 12.00747 12.02857 12.05256 12.07909
## [385] 12.10782 12.13840 12.17047 12.20370 12.23773 12.27222 12.30682 12.34117
## [393] 12.37494 12.40778 12.43932 12.46924 12.49718 12.52279 12.54573 12.56564
## [401] 12.58218 12.59726 12.61296 12.62919 12.64585 12.66287 12.68014 12.69757
## [409] 12.71507 12.73256 12.74993 12.76710 12.78397 12.80046 12.81647 12.83191
## [417] 12.84669 12.86072 12.87390 12.88614 12.89736 12.90746 12.91635 12.92393
## [425] 12.93012 12.93483 12.93796 12.93890 12.93727 12.93330 12.92720 12.91923
## [433] 12.90959 12.89854 12.88629 12.87307 12.85912 12.84466 12.82993 12.81516
## [441] 12.80057 12.78640 12.77288 12.76023 12.74869 12.73849 12.72985 12.72302
## [449] 12.71560 12.70525 12.69226 12.67689 12.65944 12.64017 12.61937 12.59731
## [457] 12.57428 12.55055 12.52639 12.50210 12.47794 12.45419 12.43114 12.40906
## [465] 12.38823 12.36892 12.35143 12.33602 12.32297 12.31257 12.30509 12.29879
## [473] 12.29181 12.28424 12.27616 12.26765 12.25880 12.24969 12.24040 12.23102
## [481] 12.22163 12.21232 12.20317 12.19426 12.18567 12.17750 12.16982 12.16271
## [489] 12.15627 12.15058 12.14571 12.14175 12.13880 12.13692 12.13620 12.13673
## [497] 12.13860 12.14234 12.14835 12.15646 12.16651 12.17835 12.19181 12.20674
## [505] 12.22296 12.24033 12.25868 12.27785 12.29769 12.31802 12.33869 12.35954
## [513] 12.38041 12.40114 12.42157 12.44154 12.46089 12.47945 12.49707 12.51359
## [521] 12.52884 12.54267 12.55491 12.56542 12.57401 12.58284 12.59403 12.60735
## [529] 12.62261 12.63961 12.65813 12.67797 12.69892 12.72079 12.74335 12.76642
## [537] 12.78977 12.81321 12.83653 12.85952 12.88198 12.90370 12.92448 12.94411
## [545] 12.96238 12.97910 12.99404 13.00701 13.01781 13.02622 13.03203 13.03506
## [553] 13.03508 13.03250 13.02794 13.02156 13.01349 13.00389 12.99288 12.98062
## [561] 12.96725 12.95292 12.93776 12.92193 12.90556 12.88880 12.87179 12.85467
## [569] 12.83760 12.82071 12.80415 12.78806 12.77258 12.75786 12.74404 12.73127
## [577] 12.71710 12.69922 12.67801 12.65386 12.62712 12.59819 12.56744 12.53524
## [585] 12.50197 12.46800 12.43372 12.39949 12.36569 12.33271 12.30090 12.27066
## [593] 12.24236 12.21636 12.19306 12.17281 12.15601 12.13999 12.12196 12.10213
## [601] 12.08068 12.05782 12.03373 12.00862 11.98268 11.95610 11.92908 11.90182
## [609] 11.87450 11.84734 11.82051 11.79422 11.76866 11.74403 11.72052 11.69833
## [617] 11.67765 11.65868 11.64162 11.62665 11.61398 11.60380 11.59631 11.59091
## [625] 11.58684 11.58402 11.58238 11.58184 11.58231 11.58374 11.58603 11.58911
## [633] 11.59291 11.59735 11.60235 11.60783 11.61372 11.61995 11.62642 11.63308
## [641] 11.63984 11.64662 11.65335 11.65996 11.66799 11.67889 11.69243 11.70837
## [649] 11.72645 11.74645 11.76812 11.79122 11.81551 11.84074 11.86668 11.89308
## [657] 11.91971 11.94633 11.97268 11.99854 12.02366 12.04779 12.07071 12.09216
## [665] 12.11191 12.12971 12.14533 12.16035 12.17647 12.19360 12.21164 12.23052
## [673] 12.25014 12.27041 12.29125 12.31257 12.33427 12.35628 12.37850 12.40084
## [681] 12.42322 12.44555 12.46774 12.48969 12.51133 12.53256 12.55330 12.57345
## [689] 12.59294 12.61166 12.62953 12.64647 12.66239 12.67719 12.69079 12.70356
## [697] 12.71596 12.72800 12.73969 12.75106 12.76210 12.77285 12.78332 12.79352
## [705] 12.80346 12.81317 12.82266 12.83194 12.84102 12.84993 12.85869 12.86729
## [713] 12.87577 12.88413 12.89240 12.90058 12.90869 12.91675 12.92477 12.93277
## [721] 12.94077 12.94873 12.95663 12.96443 12.97214 12.97974 12.98721 12.99455
## [729] 13.00173 13.00875 13.01560 13.02225 13.02870 13.03493 13.04094 13.04670
## [737] 13.05221 13.05745 13.06241 13.06707 13.07143 13.07546 13.07927 13.08296
## [745] 13.08652 13.08994 13.09320 13.09631 13.09924 13.10199 13.10455 13.10691
## [753] 13.10907 13.11100 13.11271 13.11417 13.11539 13.11635 13.11704 13.11745
## [761] 13.11758 13.11741 13.11694 13.11614 13.11502 13.11363 13.11201 13.11018
## [769] 13.10813 13.10586 13.10337 13.10067 13.09776 13.09463 13.09129 13.08773
## [777] 13.08397 13.08000 13.07582 13.07143 13.06684 13.06204 13.05704 13.05183
## [785] 13.04642 13.04081 13.03500 13.02899 13.02279 13.01638 13.00978 13.00297
## [793] 12.99596 12.98875 12.98133 12.97370 12.96586 12.95781 12.94954 12.94107
## [801] 12.93238 12.92347 12.91434 12.90499 12.89543 12.88564 12.87562 12.86538
## [809] 12.85492 12.84422 12.83330 12.82214 12.81075 12.79913 12.78727 12.77517
## [817] 12.76283 12.75026 12.73745 12.72442 12.71114 12.69764 12.68392 12.66996
## [825] 12.65578 12.64138 12.62675 12.61190 12.59683 12.58155 12.56604 12.55033
## [833] 12.53440 12.51825 12.50190
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./plotly_objs/p_wrf_b.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.25, n = 835)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 12.04979 12.04316 12.03663 12.03019 12.02386 12.01761 12.01147 12.00542
## [9] 11.99947 11.99361 11.98785 11.98218 11.97660 11.97112 11.96573 11.96044
## [17] 11.95524 11.95012 11.94511 11.94018 11.93534 11.93060 11.92594 11.92137
## [25] 11.91690 11.91251 11.90821 11.90400 11.89987 11.89584 11.89189 11.88802
## [33] 11.88425 11.88056 11.87695 11.87343 11.86999 11.86664 11.86337 11.86019
## [41] 11.85708 11.85406 11.85113 11.84827 11.84550 11.84280 11.84019 11.83766
## [49] 11.83520 11.83283 11.83055 11.82839 11.82635 11.82443 11.82262 11.82092
## [57] 11.81934 11.81788 11.81652 11.81528 11.81415 11.81312 11.81221 11.81141
## [65] 11.81072 11.81013 11.80965 11.80927 11.80901 11.80884 11.80878 11.80883
## [73] 11.80897 11.80922 11.80957 11.81002 11.81057 11.81122 11.81196 11.81281
## [81] 11.81375 11.81479 11.81592 11.81715 11.81847 11.81988 11.82139 11.82299
## [89] 11.82468 11.82646 11.82833 11.83029 11.83234 11.83447 11.83669 11.83900
## [97] 11.84139 11.84387 11.84644 11.84910 11.85187 11.85477 11.85778 11.86091
## [105] 11.86416 11.86753 11.87102 11.87463 11.87837 11.88222 11.88620 11.89031
## [113] 11.89454 11.89890 11.90339 11.90800 11.91274 11.91762 11.92262 11.92775
## [121] 11.93302 11.93842 11.94396 11.94962 11.95543 11.96137 11.96745 11.97366
## [129] 11.98002 11.98651 11.99314 11.99992 12.00684 12.01390 12.02110 12.02976
## [137] 12.04100 12.05457 12.07020 12.08764 12.10663 12.12691 12.14823 12.17031
## [145] 12.19291 12.21577 12.23861 12.26120 12.28326 12.30454 12.32478 12.34373
## [153] 12.36111 12.37667 12.39016 12.40132 12.41212 12.42466 12.43878 12.45438
## [161] 12.47130 12.48944 12.50865 12.52881 12.54978 12.57144 12.59366 12.61631
## [169] 12.63925 12.66236 12.68551 12.70857 12.73140 12.75389 12.77589 12.79728
## [177] 12.81793 12.83771 12.85649 12.87414 12.89053 12.90553 12.91901 12.93084
## [185] 12.94089 12.94903 12.95513 12.95907 12.96070 12.95993 12.95684 12.95159
## [193] 12.94438 12.93536 12.92470 12.91259 12.89918 12.88466 12.86920 12.85296
## [201] 12.83613 12.81886 12.80134 12.78373 12.76620 12.74894 12.73211 12.71588
## [209] 12.70042 12.68591 12.67252 12.66042 12.64768 12.63238 12.61472 12.59491
## [217] 12.57314 12.54961 12.52453 12.49808 12.47048 12.44192 12.41260 12.38273
## [225] 12.35249 12.32209 12.29174 12.26162 12.23194 12.20290 12.17470 12.14754
## [233] 12.12162 12.09714 12.07429 12.05328 12.03431 12.01757 12.00184 11.98575
## [241] 11.96937 11.95273 11.93588 11.91886 11.90171 11.88448 11.86721 11.84995
## [249] 11.83274 11.81562 11.79864 11.78185 11.76528 11.74897 11.73298 11.71735
## [257] 11.70212 11.68734 11.67304 11.65934 11.64627 11.63379 11.62186 11.61043
## [265] 11.59947 11.58893 11.57875 11.56891 11.55936 11.55005 11.54094 11.53198
## [273] 11.52314 11.51437 11.50562 11.49686 11.48803 11.47910 11.47002 11.46075
## [281] 11.45124 11.44145 11.43187 11.42299 11.41476 11.40714 11.40008 11.39355
## [289] 11.38750 11.38189 11.37667 11.37181 11.36726 11.36297 11.35891 11.35503
## [297] 11.35129 11.34765 11.34406 11.34047 11.33686 11.33317 11.32936 11.32539
## [305] 11.32121 11.31679 11.31208 11.30704 11.30090 11.29307 11.28372 11.27302
## [313] 11.26118 11.24835 11.23473 11.22050 11.20583 11.19091 11.17592 11.16103
## [321] 11.14644 11.13231 11.11884 11.10620 11.09457 11.08413 11.07507 11.06756
## [329] 11.06179 11.05794 11.05618 11.05513 11.05336 11.05099 11.04815 11.04494
## [337] 11.04150 11.03795 11.03440 11.03099 11.02782 11.02502 11.02272 11.02103
## [345] 11.02007 11.01997 11.02085 11.02283 11.02603 11.03057 11.03658 11.04417
## [353] 11.05388 11.06607 11.08056 11.09718 11.11579 11.13620 11.15826 11.18180
## [361] 11.20665 11.23265 11.25963 11.28743 11.31588 11.34482 11.37408 11.40349
## [369] 11.43290 11.46213 11.49102 11.51941 11.54713 11.57401 11.59989 11.62460
## [377] 11.64798 11.66986 11.69008 11.70848 11.72720 11.74833 11.77161 11.79675
## [385] 11.82348 11.85154 11.88064 11.91053 11.94091 11.97153 12.00211 12.03238
## [393] 12.06206 12.09088 12.11857 12.14485 12.16946 12.19212 12.21256 12.23051
## [401] 12.24569 12.25934 12.27284 12.28619 12.29936 12.31232 12.32506 12.33756
## [409] 12.34978 12.36172 12.37335 12.38464 12.39558 12.40614 12.41630 12.42605
## [417] 12.43535 12.44419 12.45254 12.46039 12.46771 12.47448 12.48068 12.48629
## [425] 12.49128 12.49563 12.49933 12.50189 12.50296 12.50264 12.50106 12.49835
## [433] 12.49463 12.49003 12.48466 12.47865 12.47212 12.46520 12.45802 12.45068
## [441] 12.44333 12.43607 12.42904 12.42236 12.41615 12.41053 12.40564 12.40158
## [449] 12.39691 12.39022 12.38169 12.37149 12.35982 12.34685 12.33277 12.31776
## [457] 12.30200 12.28568 12.26898 12.25208 12.23516 12.21841 12.20201 12.18614
## [465] 12.17098 12.15673 12.14355 12.13163 12.12116 12.11232 12.10529 12.09859
## [473] 12.09070 12.08175 12.07185 12.06112 12.04968 12.03766 12.02518 12.01235
## [481] 11.99930 11.98615 11.97301 11.96002 11.94728 11.93492 11.92306 11.91182
## [489] 11.90133 11.89169 11.88304 11.87549 11.86916 11.86418 11.86066 11.85873
## [497] 11.85851 11.86004 11.86323 11.86797 11.87414 11.88163 11.89032 11.90011
## [505] 11.91088 11.92252 11.93492 11.94795 11.96152 11.97550 11.98979 12.00427
## [513] 12.01883 12.03336 12.04773 12.06185 12.07560 12.08886 12.10152 12.11348
## [521] 12.12460 12.13480 12.14394 12.15192 12.15863 12.16553 12.17406 12.18410
## [529] 12.19550 12.20811 12.22181 12.23644 12.25187 12.26797 12.28458 12.30157
## [537] 12.31880 12.33613 12.35342 12.37053 12.38732 12.40364 12.41937 12.43436
## [545] 12.44847 12.46155 12.47348 12.48410 12.49329 12.50089 12.50677 12.51080
## [553] 12.51282 12.51353 12.51374 12.51347 12.51274 12.51157 12.50998 12.50800
## [561] 12.50564 12.50294 12.49992 12.49659 12.49298 12.48911 12.48500 12.48068
## [569] 12.47617 12.47149 12.46666 12.46171 12.45666 12.45153 12.44634 12.44112
## [577] 12.43455 12.42547 12.41413 12.40077 12.38565 12.36899 12.35106 12.33210
## [585] 12.31235 12.29206 12.27149 12.25086 12.23044 12.21046 12.19118 12.17284
## [593] 12.15568 12.13996 12.12591 12.11380 12.10385 12.09410 12.08252 12.06927
## [601] 12.05451 12.03843 12.02118 12.00293 11.98384 11.96409 11.94384 11.92326
## [609] 11.90251 11.88177 11.86119 11.84094 11.82120 11.80213 11.78389 11.76665
## [617] 11.75058 11.73585 11.72261 11.71105 11.70132 11.69360 11.68805 11.68428
## [625] 11.68177 11.68041 11.68013 11.68083 11.68242 11.68483 11.68795 11.69170
## [633] 11.69600 11.70075 11.70587 11.71127 11.71686 11.72256 11.72827 11.73391
## [641] 11.73939 11.74462 11.74952 11.75399 11.75929 11.76658 11.77569 11.78646
## [649] 11.79870 11.81225 11.82693 11.84256 11.85897 11.87599 11.89344 11.91115
## [657] 11.92895 11.94665 11.96410 11.98110 11.99749 12.01310 12.02774 12.04125
## [665] 12.05345 12.06417 12.07324 12.08167 12.09059 12.09995 12.10971 12.11983
## [673] 12.13026 12.14096 12.15189 12.16300 12.17425 12.18559 12.19699 12.20840
## [681] 12.21978 12.23108 12.24226 12.25327 12.26408 12.27464 12.28491 12.29484
## [689] 12.30440 12.31353 12.32219 12.33035 12.33795 12.34496 12.35132 12.35710
## [697] 12.36240 12.36723 12.37165 12.37567 12.37934 12.38268 12.38573 12.38852
## [705] 12.39109 12.39346 12.39567 12.39776 12.39974 12.40167 12.40357 12.40547
## [713] 12.40740 12.40940 12.41151 12.41375 12.41615 12.41876 12.42159 12.42469
## [721] 12.42809 12.43152 12.43469 12.43762 12.44034 12.44286 12.44520 12.44738
## [729] 12.44942 12.45133 12.45313 12.45485 12.45650 12.45810 12.45967 12.46122
## [737] 12.46278 12.46436 12.46599 12.46768 12.46944 12.47131 12.47328 12.47535
## [745] 12.47750 12.47972 12.48198 12.48427 12.48657 12.48886 12.49113 12.49335
## [753] 12.49552 12.49761 12.49960 12.50148 12.50323 12.50483 12.50627 12.50752
## [761] 12.50858 12.50942 12.51002 12.51036 12.51044 12.51035 12.51020 12.50998
## [769] 12.50970 12.50936 12.50895 12.50847 12.50792 12.50729 12.50659 12.50582
## [777] 12.50496 12.50403 12.50301 12.50191 12.50072 12.49944 12.49807 12.49661
## [785] 12.49506 12.49341 12.49168 12.48989 12.48805 12.48613 12.48416 12.48211
## [793] 12.48000 12.47781 12.47555 12.47322 12.47081 12.46832 12.46574 12.46309
## [801] 12.46034 12.45751 12.45460 12.45158 12.44848 12.44528 12.44198 12.43859
## [809] 12.43509 12.43149 12.42778 12.42396 12.42004 12.41600 12.41185 12.40756
## [817] 12.40316 12.39863 12.39399 12.38923 12.38436 12.37938 12.37430 12.36910
## [825] 12.36381 12.35841 12.35292 12.34733 12.34165 12.33588 12.33002 12.32408
## [833] 12.31805 12.31195 12.30576
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./plotly_objs/p_wrf_c.rda")
save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
save(both_ymina, file = "./plotly_objs/both_ymina.rda")
save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
save(both_yminb, file = "./plotly_objs/both_yminb.rda")
save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
save(both_yminc, file = "./plotly_objs/both_yminc.rda")
save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")